﻿using DatabaseAccess;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Liguo.Administration
{
    public partial class AddNewAdministrator : System.Web.UI.Page
    {
        SqlIt sql = new SqlIt();
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void submit_Click(object sender, EventArgs e)
        {
            string salt = Utilities.GetSalt();
            string username = AdminName.Text.Trim();
            string password = Password1.Value.ToString();
            //Response.Write(username + password+ salt);
            if (username.Length == 0 ||  password.Length == 0)
            {
                Response.Write("<script>alert('无效输入！')</script>");
                return;
            }
            string pw = Utilities.GetMD5(password + salt);
            Dictionary<string, string> info = new Dictionary<string, string>();
            info["AdminName"] = username;
            info["Password"] = pw;
            info["Salt"] = salt;
            info["Status"] = "1";
            info["AdminLevel"] = "1";
            sql.AddMess("AdminInfo", info);
            Response.Write("<script>alert('添加成功！')</script>");
            return;
            // 
        }
    }
}